import Vue from 'vue'
import Vuex from 'vuex'
import user from './modules/user'
Vue.use(Vuex)

const store = new Vuex.Store({
  strict: true,
  state: {
    count: 100,
    title: '这是一个title',
    list: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  },
  mutations: {
    addCount (state, num) {
      state.count += num
    },
    reduceCount (state, num) {
      state.count -= num
    },
    become (state, num) {
      state.count = num
    }
  },
  actions: {
    changeCountAsync (context, num) {
      setTimeout(() => {
        context.commit('become', num)
      }, 1000)
    }
  },
  getters: {
    filterList (state) {
      return state.list.filter((e) => e > 5)
    }
  },
  modules: {
    user
  }
})

export default store
